package com.dzu.gulimall.search.controller;

import com.dzu.gulimall.search.service.MallSearchService;
import com.dzu.gulimall.search.vo.SearchParam;
import com.dzu.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author by ZhaoDong
 * @Classname SearchController
 * @Description search页面跳转
 * @Date 2021/7/9 15:01
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model ){

        // 1、根据 从页面传递过来的查询参数，去es中检索商品
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result",result);

        return "list";
    }
}
